package com.qf.wangqing.sportsnews.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.qf.wangqing.sportsnews.bean.newsbean.ChannelsEntity;
import com.qf.wangqing.sportsnews.fragment.NewsBaseFragment;

import java.util.List;

/**
 * Created by WangQing on 2016/12/15.
 */

public class NewsPagerAdapter extends FragmentPagerAdapter{
    private List<ChannelsEntity> list;

    public NewsPagerAdapter(FragmentManager fm, List<ChannelsEntity> list) {
        super(fm);
        this.list = list;
    }

    //ChannelsEntity 里的id 对应 各个fragment里的url 中的 channel_id
    @Override
    public Fragment getItem(int position) {
        return NewsBaseFragment.newInstance(list.get(position).getId());
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return list.get(position).getName();
    }
}
